<?php
/**
 * Author：晴天 QQ：1186258278
 * Creation：2020/4/27 13:27
 * Filename：evaluate.php
 * 商品评价
 */
if (!defined('IN_CRONLITE')) die();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" style="<?= background::image() == false ? 'background:linear-gradient(to left, #70e1f5, #ffd194);' : background::image() ?>">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <meta name="renderer" content="webkit"/>
    <meta name="force-rendering" content="webkit"/>
    <title>商品评论 - <?= $conf['sitename'] . ($conf['title'] == '' ? '' : ' - ' . $conf['title']) ?></title>
    <meta name="keywords" content="<?= $conf['keywords'] ?>">
    <meta name="description" content="<?= $conf['description'] ?>">
    <link rel="stylesheet" type="text/css"
          href="<?php echo $cdnserver; ?>assets/layui/css/layui.css?var=<?= $accredit['versions'] ?>"/>
    <link type="text/css" rel="stylesheet"
          href="<?php echo $cdnserver; ?>assets/AppStore/css2/style.css?var=<?= $accredit['versions'] ?>"/>
</head>
<style>
    .score {
        float: right;
        margin-left: 1rem;
        margin-top: -0.6rem;
        font-size: 10px !important;
    }

    .image_sc {
        margin: 0.3em;
        box-shadow: 3px 3px 16px #eee;
        border-radius: 0.5em;
        width: 50px;
        height: 50px;
    }
</style>
<body>
<div class="headerbox">
    <div class="header">
        <div class="headerL">
            <a onclick="javascript:history.back(-1)" class="goback"><img src="/assets/AppStore/images/goback.png"/></a>
        </div>
        <div class="headerC">
            <p>评价</p>
        </div>
        <div class="headerR"></div>
    </div>
</div>
<div class="clear"></div>
<div class="hbox"></div>
<div class="layui-elem-quote" style="font-size: 1.2em" id="score">综合评分：<span class="score"></span></div>
<div class="xqpj bor"></div>
<script src="<?php echo $cdnpublic ?>jquery/1.12.4/jquery.min.js"></script>
<script src="<?php echo $cdnserver; ?>assets/layui/layui.all.js"></script>
<script>
    $.ajax({
        type: "POST",
        url: '/ajax.php?act=Discuss',
        data: {
            gid: <?=$_QET['gid']?>,
            type: 'List',
        },
        dataType: "json",
        success: function (data) {
            if (data.code == 1) {
                var content = '';
                $.each(data.data, function (key, val) {
                    content += '<div class="xqpjbox">\n' +
                        '        <div class="pj1">\n' +
                        '            <img src="' + val.n_image + '"/>\n' +
                        '            <span>' + val.name + '</span> <span style="color: cadetblue">' + val['score'] + '分</span>\n' +
                        '        </div>\n' +
                        '        <div class="pj2">' + val.content + '</div>' + (val['image'] != '' ? image('' + val['image'] + '') : '') + '\n' +
                        '        <div class="pj3">' + val.addtime + '  |  ' + val.describe + '</div>\n' +
                        '    </div>';
                });
                $(".bor").html(content);

                $(".image_sc").click(function () {
                    layer.open({
                        title: '评论图片预览',
                        content: '<div style="text-align: center"><img src="' + $(this).attr('src') + '" style="max-width: 350px;max-height: 350px;" /></div>',
                        skin: 'layui-layer-rim',
                        btn: false,
                        shade: [0.8, '#393D49'],
                        shadeClose: true,
                    });
                });

                layui.use('flow', function () {
                    var flow = layui.flow;
                    flow.lazyimg();
                });

                layui.use('rate', function () {
                    var rate = layui.rate;
                    var ins1 = rate.render({
                        elem: '#score .score'
                        , value: data.avg
                        , theme: '#FFB800'
                        , readonly: true
                        , length: 5
                        , half: true
                    });
                });
            }
        },
        error: function () {
            layer.alert('商品推荐获取失败！');
        }
    });

    function image(img) {
        arr = img.split('|');
        con = '';
        i = 1;
        $.each(arr, function (key, val) {
            if (i == 3) {
                s = '<br>';
                i = 1;
            } else {
                s = '';
                ++i;
            }
            con += '<img lay-src="' + val + '" class="image_sc" />' + s;

        });
        return con;
    }
</script>
</body>
</html>

